<template>
    <rx-dialog class="rx-form-boList-dialog" :options="dialogConfig" @close="close" @confirm="confirm">
    <form-bo-list-preview class="rx-popup"
                          ref="formBoList"
                          @init="init"
                          :alias="alias"
                          :pmtAlias="pmtAlias"
                          @close="close"
                          :single="single"
                          :params="params">
    </form-bo-list-preview>
    </rx-dialog>
</template>

<script>
import BaseDialogComponent from "@/components/layer/BaseDialogComponent.js";
import FormBoListPreview from './FormBoListPreview';
import RxDialog from "@/components/RxDialog";
export default {
    name: "FormBoListDialog",
    mixins: [BaseDialogComponent],
    components: {
        FormBoListPreview,
        RxDialog
    },
    provide(){
        return {
            /**
             * 将当前实例向下传递.
             */
            dialogVm:this
        }
    },
    data(){
        return {
            dialogConfig:{
                title:""
            },
            eventName:'',
            /**
             * 对话框别名
             */
            alias:'',
            /**
             * 数据权限别名
             */
            pmtAlias:'',
            /**
             * 是否单选
             */
            single:true,
            /**
             * 参数例如 name=ray&address=guangzhou
             */
            params:'',
            /**
             * 初始化数据.
             * {
             *      keyField:"",
             *      selected:[]
             *  }
             */
            initData:{},
            formBoListData:{},
        }
    },
    onLoad(params){
        let openListParams = uni.getStorageSync('openListParams')
        let obj = openListParams.params;
        this.eventName = openListParams.eventName
        this.alias = obj.alias;
        this.pmtAlias = obj.pmtAlias;
        this.single = obj.single;
        this.params = obj.params;
        this.initData = obj.initData
    },
    methods:{
        init(record){
            this.dialogConfig.title=record.name;
        },
        confirm(){
            let self=this;
            let rows=this.$refs.formBoList.getSelected();
            uni.navigateBack({
                delta:1,
                success:function() {
                    uni.$emit(self.eventName,{
                        action:'ok',
                        data:{
                            rows:rows
                        }
                    })
                }
            })
        },
        close(){
            uni.navigateBack({
                delta:1,
                success:function() {
                    uni.$emit(self.eventName,{
                        action:'ok',
                    })
                }
            })
        },
    }
}
</script>

<style scoped>
.rx-form-boList-dialog>>> .m-mobile-roll {
    padding: 0px !important;
}
</style>
